<?php
function getMaxVal($scIndex, $qtySesh)
{
	//0 - itemID, 1 - itemSize, 2 - itemCat (mwa)
	$tables = array();
	$tables[0] = 'ex_gallery_'.$scIndex[2];
	
	$fields = array();
	$fields[0] = 'deactivate';
	
	$whereClause = 'itemID="'.$scIndex[0].'"';
	
	$data = SQLRecover($tables, $fields, $whereClause);
	
	
	
	return ($data['deactivate'][0] <= $qtySesh ? $data['deactivate'][0] : $qtySesh);
}
function getCartItems()
{
	$totalNo = 0;
	if(get('page') != 'cart')
	{
		if(!isset($_SESSION['cart']))
		{
			return 0;
		}
		//READ: MACHINE LANG > SEARCHABLE LANG
		for ($i=0; $i<sizeOf($_SESSION['cart']); $i++)
		{
			$dataSession = explode('|', $_SESSION['cart'][$i]);
			$itemIDSize[$i] = $dataSession[0].'|'.$dataSession[3].'|'.$dataSession[1];
			$itemQty[$i] = $dataSession[2];
		}
		$shoppingCartItems = array();
		//GET CART VALUES
		for ($i=0; $i<sizeOf($itemIDSize); $i++)
		{
			if(!isset($shoppingCartItems[$itemIDSize[$i]]))
			{
				$shoppingCartItems[$itemIDSize[$i]] = 0;
			}
			$shoppingCartItems[$itemIDSize[$i]] += $itemQty[$i];
		}
		
		$shoppingCartIndices = array();
		$add = true;
		//GET ALL INDIV ITEM + SIZE
		for ($i=0; $i<sizeOf($itemIDSize); $i++)
		{
			if(!isset($shoppingCartIndices[0]))
			{
				$shoppingCartIndices[0] = $itemIDSize[$i];
				$add = false;
			}
			else
			{
				$add = true;
				for ($j=0; $j<sizeOf($shoppingCartIndices); $j++)
				{
					if($shoppingCartIndices[$j] == $itemIDSize[$i])
					{
						$add = false;
					}
				}
			}
			
			if($add)
			{
				$shoppingCartIndices[sizeOf($shoppingCartIndices)] = $itemIDSize[$i];
			}
		}
		
		for ($i=0; $i<sizeOf($shoppingCartIndices); $i++)
		{
			$totalNo += getMaxVal(explode('|', $shoppingCartIndices[$i]), $shoppingCartItems[$shoppingCartIndices[$i]]);
		}
	}
	return $totalNo;
}
//DYNCSS - Global
$webkit = (userEngine('Webkit') ? true : false);
$windows = (userEngine('Windows') ? true : false);
$chrome = (userEngine('Chrome') ? true : false);
if($webkit)
{
	$css = '
	<style type="text/css" media="all">
	<!--
	#searchBar{
	width: 114px;
	height: 15px;
	top: -1px;
	}
	-->
	</style>';
}
else
{
	if($windows)
	{
		$css = '
		<style type="text/css" media="all">
		<!--
		#searchBar{
			width: 114px;
			height: 14px;
			top: 0px;
		}
		-->
		</style>
		';
	}
	else
	{
		$css = '
		<style type="text/css" media="all">
		<!--
		#searchBar{
			width: 114px;
			height: 12px;
			top: 0px;
		}
		-->
		</style>
		';
	}
}
if($chrome && $windows)
{
	$css = '
	<style type="text/css" media="all">
	<!--
	#searchBar{
	width: 117px;
	height: 15px;
	top: -1px;
	}
	-->
	</style>';
}

echo $css;
?>